var a = getApp();

Page({
    data: {
        activeName: "1",
        card_id: 0,
        active: 0,
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(a) {
        this.setData({
            card_id: a.cardId
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    changeActive: function(a) {
        console.log(a, this.data.active), this.data.active = a.detail.index, this.getData();
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    initData: function() {
        this.data.page = 1, this.data.isLoadMore = !0, this.data.total_page = 0;
    },
    getData: function() {
        var t = this;
        this.initData();
        var i = a.getNetAddresss("plugin.picking-card.frontend.pickingCard.bindMemberCardList");
        a._getNetWork({
            url: i,
            data: {
                status: this.data.active,
                card_id: this.data.card_id
            },
            success: function(a) {
                var i = a.data;
                t.setData({
                    listData: i.data.data,
                    total_count: i.data.total_count,
                    isused_count: i.data.isused_count,
                    notused_count: i.data.notused_count
                }), t.data.isLoadMore = !0, t.data.total_page = i.data.last_page, t.data.total_page || (t.data.total_page = 0);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var i = a.getNetAddresss("plugin.picking-card.frontend.pickingCard.bindMemberCardList");
            a._postNetWork({
                url: i,
                data: {
                    page: this.data.page,
                    status: this.data.active,
                    card_id: this.data.card_id
                },
                success: function(a) {
                    var i = a.data;
                    if (t.data.isLoadMore = !0, 1 === i.result) {
                        var e = i.data.data, d = t.data.listData.concat(e);
                        t.setData({
                            listData: d
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    changeCollapse: function(a) {
        this.setData({
            activeName: a.detail
        });
    },
    onShareAppMessage: function() {}
});